#!/bin/bash
# mondorestore.sh wrapper


verbose=""
output_directory="/mnt/sda4"
mount_directory="/mnt/share"

source emabs_common.sh

usage()
{
cat << EOF
usage: $0 -s 192.168.1.1:/share/ -f /path/to/isofile.iso

Automate system restoration from Mondo ISOs (both full and differential)

OPTIONS:
   -h      Show this message
   -s      NFS server address and share
   -f      Path to Full backup ISO
   -v      Verbose

Examples:
    $0 -s 192.168.1.1:/share/ -f /isos/gentoo-1.iso
EOF
}

while getopts "hs:f:v" OPTION
do
     case $OPTION in
         h)
             usage
             exit
             ;;
         f)
             # path to full backup ISO
             iso_full_input_path=$OPTARG
             ;;
         s)
             # path to full backup ISO
             nfs_server=$OPTARG
             ;;
         v)
             verbose="-v"
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

if [[ ! -z $iso_full_input_path ]] | [[ -z $nfs_server ]]
then
    usage
    exit 1
fi

exec_cmd "mount -t nfs $nfs_server $mount_directory"
exec_cmd "mondorestore.sh -f $mount_directory/$iso_full_input_path -o $output_directory $verbose"

